<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box{
            width: 100px;height: 100px;background: red;padding-top: 40px;margin: 5px;
        }
    </style>
</head>
<body>
    <div class="box"></div>
</body>
<script>
    const obox=document.querySelector(".box")

    console.log(getStyle(obox,"width"));
    console.log(getStyle(obox,"height"));
    console.log(getStyle(obox,"background"));
    console.log(getStyle(obox,"margin"));
    console.log(getStyle(obox,"paddingTop"));
    // console.log(getStyle(obox,"width"));
    function getStyle(ele, attr){
        if(ele.currentStyle){
            return ele.currentStyle[attr];
        }else{
            return getComputedStyle(ele)[attr];
        }
    }
</script>
</html>